package aircraft;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Objects;

public class Images {
    public static BufferedImage sky;
    public static BufferedImage bullet;
    public static BufferedImage[] heros;
    public static BufferedImage[] airs;
    public static BufferedImage[] bairs;
    public static BufferedImage[] bees;
    public static BufferedImage start;
    public static BufferedImage pause;
    public static BufferedImage gameover;
    public static BufferedImage airbullet;

    static {
        sky = readImage("background.png");
        bullet = readImage("bullet.png");
        heros = new BufferedImage[2];
        heros[0] = readImage("hero0.png");
        heros[1] = readImage("hero1.png");
        airs = new BufferedImage[5];
        bairs = new BufferedImage[5];
        bees = new BufferedImage[5];
        airs[0] = readImage("airplane.png");
        bairs[0] = readImage("bigairplane.png");
        bees[0] = readImage("bee.png");
        for (int i = 1; i < 5; i++) {
            airs[i] = readImage("bom" + i + ".png");
            bairs[i] = readImage("bom" + i + ".png");
            bees[i] = readImage("bom" + i + ".png");
        }
        start = readImage("start.png");
        pause = readImage("pause.png");
        gameover = readImage("gameover.png");
        airbullet = readImage("airbullet.png");

    }

    public static BufferedImage readImage(String fileName) {
        BufferedImage img = null;
        try {
            img = ImageIO.read(Objects.requireNonNull(Thread.currentThread()
                    .getContextClassLoader().getResource("img/" + fileName)));
            return img;
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException();
        }
    }

}
